<?php 
namespace Emos\Field;
use Emos\Common;

class Checkbox extends AbstractControl{
    protected $unchecked = 0;
    protected $checked = 1;    
    protected $remark = null;
    
    public function setValues($checked, $unchecked) {
        $this->checked = $checked;
        $this->unchecked = $unchecked;
        return $this;
    }
    
    public function setRemark($remark) {
        $this->remark = $remark;
        return $this;
    }
    
    public function html() {
        $chk = ($this->value == $this->checked) ? ' checked' : '';        
        return 
            "<input type='hidden' name='{$this->htmlName}' value='".Common::plain($this->unchecked)."' />".
            "<input type='checkbox' name='{$this->htmlName}' value='".Common::plain($this->checked)."'{$chk}/>".
            $this->remark;
   }
}